package com.pactera.asmp.server.service;

import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @ProjectName: asmp-server
 * @Package com.pactera.asmp.server.service.redis
 * @ClassName: IRedisService
 * @Description: Redis Operation API
 * @Date 2020/05/30 11:09
 * @Author lvzhiqiang
 * @Version 1.0
 */
public interface IRedisService {

    /**
     * @param key
     * @param value
     */
    void set(String key, String value);

    /**
     *
     * @param key
     * @param value
     * @param db
     * @param flagJson
     * @param timeOut
     * @return
     */
    boolean set(final String key, Object value,int db,boolean flagJson,Long timeOut);

    /**
     * get
     * @param key
     * @return
     */
    String get(String key);

    /**
     * get
     * @param key
     * @param db
     * @return
     */
    Object  get(String key, int db);

    /**
     * setex
     * @param key
     * @param value
     * @param timeUnit
     * @param time
     */
    void setex(String key, String value, TimeUnit timeUnit, int time);

    /**
     * hset
     * @param hashKey
     * @param subKey
     * @param value
     * @param time
     * @param dbIndex
     */
    void hset(String hashKey, String subKey, String value, long time, int dbIndex);

    /**
     * hasKey
     * @param key
     * @return boolean
     */
    boolean hasKey(String key);

    void remove(final String key ,int db);

    void remove(final String key);

    /**
     * getRedisTemplate
     * @return StringRedisTemplate
     */
    StringRedisTemplate getRedisTemplate();

    int getExpire(int exprie,int randomScope);
}
